#pragma once

#include <vector>
#include "SGD Wrappers\CSGD_TextureManager.h"
#include "Frame.h"

class Animation
{
	int		curFrame;
	int		maxFrames;
	float	timeWaited;
	bool	isPlaying;
	bool	isLooping;
	float	playSpeed;
	int		imageID;
	std::wstring fileName;

	std::vector<Frame*> frameArray;

	CSGD_TextureManager* pTM;

public:
	Animation();
	~Animation();
	void Initialize(std::vector<Frame*> frames, std::wstring name);
	bool LoadAnimationFromFile(std::string file, int index = 0);
	void SaveAnimationtoFile(std::string file);
	void Update(float elapsed);
	void Render(int x, int y, float scale, DWORD color, bool isFlipped);
	void Play(int looping = -1, float speed = -1);
	void Stop();
	void Resume();

	std::wstring GetFileName() {return fileName;}
	void SetFileName(std::wstring tmp) {fileName = tmp;}

	bool IsPlaying() {return isPlaying;}
	RECT GetCollsionRect()	{return frameArray[curFrame]->GetColRect();}
	/*int GetWidth()		{return frameArray[0]->GetWidth();}
	int GetHeight()		{return frameArray[0]->GetHeight();}*/
};
